<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>promise异常传透</h1>
    <script>
        // 创建一个promise对象
        const p = new Promise((resolve, reject)=>{
            //resolve(100);
            throw "无操作权限！";
            //reject("error");
        });

        // 链式调用then
        p.then(v => {
            console.log(v);
        }).then(v => {
            console.log(v);
        }).then(v => {
            console.log(v);
        }, r => {
            // console.info(r);
            // console.log(r);
            // console.warn(r);
            console.error(r);
        });

        // 因为错误具有传透效果，所以我们可以在链式调用then中最后一个上面加上失败的回调即可
        // 我们可以改成下面的处理方式，使用catch
        p.then(v => {
            console.log(v);
        }).then(v => {
            console.log(v);
        }).then(v => {
            console.log(v);
        }).catch(e => {
            console.error(e);
        });
    </script>
</body>
</html>